<html>
<head><meta charset="utf-8"><title>k#  and conflicts between macros and user symbols · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html">k#  and conflicts between macros and user symbols</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232501295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232501295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232501295">(Mar 30 2021 at 21:30)</a>:</h4>
<p>I'm wondering if this has some additional potential. For example, a few months back, I raised an issue on IRL (&lt;<a href="https://internals.rust-lang.org/t/reserved-names-for-no-mangle-and-link-name/13737">https://internals.rust-lang.org/t/reserved-names-for-no-mangle-and-link-name/13737</a>&gt;), and part of it included the fact that standard library macros for implementations may need to define special names, but technically cannot without the potential to conflict with user-defined names in the same scope (and, unless those names are specified, limiting implementation, this would include portability issues). <br>
If part of this indicated that the Rust language would never reverse and use keywords of certain forms (say, ones that start with two underscores, or an underscore, followed by a capital letter), then implementations could (unstably) overload the <code>k#</code> syntax in special cases with those forms. It could also be used (hopefully, along with feature gates), to enable vendor-specific extensions. Just an idea, though.</p>



<a name="232506386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232506386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232506386">(Mar 30 2021 at 22:15)</a>:</h4>
<p><span class="user-mention" data-user-id="257758">@Connor Horman</span> Part of the point of the <code>k#</code> syntax would be to <em>never</em> conflict with anything user-defined.</p>



<a name="232506409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232506409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232506409">(Mar 30 2021 at 22:15)</a>:</h4>
<p>That's less of an issue with standard library names, because if you define your own, it can shadow.</p>



<a name="232506495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232506495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232506495">(Mar 30 2021 at 22:16)</a>:</h4>
<p>(We'd need to make sure that was actually the case, and all such names are shadowable.)</p>



<a name="232506560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232506560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232506560">(Mar 30 2021 at 22:17)</a>:</h4>
<p>Also, "this could enable vendor-specific extensions" is not a selling point for a feature. :)</p>



<a name="232506973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232506973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232506973">(Mar 30 2021 at 22:21)</a>:</h4>
<p>I don't think it'd be necessary to specify that Rust would never reserve keywords of particular forms, because any such keywords would use the <code>k#</code> system to avoid conflict with existing code.</p>



<a name="232507107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232507107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232507107">(Mar 30 2021 at 22:22)</a>:</h4>
<p>And I think the generalized solution for the macro issue would be hygiene; we need a <code>gensym</code> mechanism for temporary names.</p>



<a name="232507632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232507632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232507632">(Mar 30 2021 at 22:28)</a>:</h4>
<p>(That's separate from the linked issue above, which is about symbol namespacing in the final binary. That's a different problem.)</p>



<a name="232507668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232507668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232507668">(Mar 30 2021 at 22:28)</a>:</h4>
<p>Or a macros 2.0 "this is in a distinct hygiene context distinct from anything else, so can only be used when it's this token passed around" kind of thing somehow.  (Which is basically a gensym, but without exactly ever generating a name.)</p>



<a name="232508625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232508625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232508625">(Mar 30 2021 at 22:38)</a>:</h4>
<p>Sure; either a generated name or a unique namespace works.</p>



<a name="232508638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232508638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232508638">(Mar 30 2021 at 22:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/k.23.20.2C.20r.23.24.20.2C.20editions/near/232506560">said</a>:</p>
<blockquote>
<p>Also, "this could enable vendor-specific extensions" is not a selling point for a feature. :)</p>
</blockquote>
<p>I know, that was just an additional benefit (at least to me, as it makes macros like <code>asm!</code> a lot less magical, and 50% less headache, because I can be expand the macro to something instead of attaching the macro expander to the ir generator). </p>
<blockquote>
<p>I don't think it'd be necessary to specify that Rust would never reserve keywords of particular forms, because any such keywords would use the <code>k#</code> system to avoid conflict with existing code.</p>
</blockquote>
<p>It's more of a set of keywords that implementations can use (in conjunction with the <code>k#</code> syntax) for various purposes and never run into problems, and they can rely on it never conflicting with a keyword defined in the future.</p>



<a name="232508725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232508725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232508725">(Mar 30 2021 at 22:39)</a>:</h4>
<p>I think the right way to not conflict with Rust is to have a discussion with upstream Rust.</p>



<a name="232508757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232508757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232508757">(Mar 30 2021 at 22:39)</a>:</h4>
<p>I don't think we should reserve a namespace of "portions of the design/syntax space we won't touch".</p>



<a name="232508832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232508832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232508832">(Mar 30 2021 at 22:40)</a>:</h4>
<p>In any case, I think this is drifting off topic.</p>



<a name="232508920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232508920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232508920">(Mar 30 2021 at 22:41)</a>:</h4>
<p>Mind if I move this branch of the discussion to a different topic?</p>



<a name="232509335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232509335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232509335">(Mar 30 2021 at 22:45)</a>:</h4>
<p>Nope.</p>



<a name="232510215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232510215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232510215">(Mar 30 2021 at 22:53)</a>:</h4>
<p>Done.</p>



<a name="232512202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232512202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232512202">(Mar 30 2021 at 23:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="257758">Connor Horman</span> <a href="#narrow/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols/near/232508638">said</a>:</p>
<blockquote>
<p>at least to me, as it makes macros like <code>asm!</code> a lot less magical, and 50% less headache, because I can be expand the macro to something instead of attaching the macro expander to the ir generator</p>
</blockquote>
<p>This definitely does open the possibility of having <code>asm!(foo)</code> expand to <code>k#asm { foo }</code> or similar.  I don't know enough about the implementation strategy in the compiler to know for sure whether that'd be a valuable change, though.</p>



<a name="232513937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/k%23%20%20and%20conflicts%20between%20macros%20and%20user%20symbols/near/232513937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/k.23.20.20and.20conflicts.20between.20macros.20and.20user.20symbols.html#232513937">(Mar 30 2021 at 23:34)</a>:</h4>
<p>It wouldn't necessarily need to be a requirement, but rather an implementation-detail.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>